package com.core.reach.oauth2resources.api;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.security.Principal;
import java.util.UUID;

/**
 * @author Mr_zhangmu
 * @version V1.0
 * @description: TODO
 * @date 2020/6/18 17:06
 **/
@RestController
@RequestMapping
public class OAuthApi {

    @GetMapping("/res")
    public String getResources() {
        return UUID.randomUUID().toString();
    }

    @RequestMapping("/user")
    public Principal user(Principal principal) {
        //principal在经过security拦截后，是org.springframework.security.authentication.UsernamePasswordAuthenticationToken
        //在经OAuth2拦截后，是OAuth2Authentication
        return principal;
    }


}
